package com.pdd.commons.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author:liyangpeng
 * @date:2019/6/3 19:23
 */
public class StringUtil {
    /**
     * 生成key
     * @return
     */
    public static String getCtsRandom(){
        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("YYMMddHHmmssSSS");
        String cts=simpleDateFormat.format(new Date());
        Long code=Long.MAX_VALUE-Long.valueOf(cts+getRandom());
        return String.valueOf(code);
    }

    /**
     * 4位随机数生成
     * @return
     */
    public static int getRandom(){
        return (int)((Math.random()*9+1)*1000);
    }

    public static void main(String[] args) {
        System.out.println(getCtsRandom());
    }
}
